|
|
|
|
|
|
|
MouseDown event, then when you continue and click the mouse button down again to get to the MouseUp routine, the breakpoint in the MouseDown event will be hit again. Thus, you would never get to the MouseUp event. The only way around this is to remove the breakpoint in the MouseDown event. |
|
|
|
|
|
|
|
|
Breaking During a KeyDown Event |
|
|
|
|
|
|
|
|
If you are testing a KeyDown event, the same considerations discussed previously hold true for the KeyDown and KeyUp events. |
|
|
|
|
|
|
|
|
On this day, you have seen all of the tools, tips, techniques, and Visual Basic statements that you have available to you when debugging your application. By using all of these together, you will be able to test your application and fix almost every problem that there might be. Of course, I said almost every problem; you will never get your application to a point where problems will never happen again. Debugging can be a very daunting task after you have finally completed your application. However, there are several ways to simplify this task. The following list are just some of the tips that I use when debugging applications that I have created: |
|
|
|
|
|
|
|
|
When the application doesn't produce correct results, browse through your code looking for statements that night have caused the problem. Then set breakpoints at one or more of these statements and restart the application. |
|
|
|
|
|
|
|
|
When the program breaks, display the values of any important variables and properties by using the Immediate window. |
|
|
|
|
|
|
|
|
Use the Break on All Errors option to determine where an error occurred. Then, step through your code, using Watch expressions and the Locals window to monitor how values change during the process. |
|
|
|
|
|
|
|
|
If an error occurs in a loop, define a Break expression to determine where the problem occurs. |
|
|
|
|
|
|
|
|
If you determine that a variable or property is causing problems in your application, use a Debug.Assert statement to halt execution when the wrong value is assigned to the variable or property. |
|
|
|
|
|
|
|
|
As you have seen, debugging is something that is learned but not necessarily taught. There is an art to the debugging process, and just because you know how to use the tools, doesn't imply that you will be doing a good job when debugging the application. You should strive to understand the process and think of the application code as whole units instead of statements. This will help you understand and discover where things may be going wrong. |
|
|
|
|
|